package com.stylefeng.guns.modular.system.warpper;

import java.text.DecimalFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang.StringUtils;

import com.stylefeng.guns.core.base.warpper.BaseControllerWarpper;
import com.stylefeng.guns.core.common.constant.factory.ConstantFactory;
import com.stylefeng.guns.core.util.DateUtil;
import com.stylefeng.guns.modular.system.model.Gdhs;
import com.stylefeng.guns.modular.system.model.Gpdata;

public class NiubilityBrankWarpper extends BaseControllerWarpper{

	public NiubilityBrankWarpper(List<Map<String, Object>> list) {
        super(list);
    }

    @Override
    public void warpTheMap(Map<String, Object> map) {
    	Gdhs gdhs =  ConstantFactory.me().getGdhs((String)map.get("gScode"));
    	Gpdata gpdata = ConstantFactory.me().getGpdata((String)map.get("gScode"));
    	DecimalFormat df = new DecimalFormat("0.00");
    	if(gdhs == null || gpdata == null) return;
    	StringBuffer result = new StringBuffer();
    	result.append("<font color='red'><b>" + map.get("gSname") +"</b></font></br>私募(阳光):" + (gpdata.getgIsYgsmNum() > 0 ? "<font color='red'><b>"+gpdata.getgIsYgsmNum()+"</b></font>" : "<font color='green'><b>"+gpdata.getgIsYgsmNum()+"</b></font>"))
		.append("&nbsp&nbsp|&nbsp&nbsp")
		.append("私募(个人):" + (gpdata.getgIsGrsmNum() > 0 ? "<font color='red'><b>"+gpdata.getgIsGrsmNum()+"</b></font>" : "<font color='green'><b>"+gpdata.getgIsGrsmNum()+"</b></font>"))
		.append("&nbsp&nbsp|&nbsp&nbsp")
		.append("QFILL:" + (gpdata.getgIsQfillNum() > 0 ? "<font color='red'><b>"+gpdata.getgIsQfillNum()+"</b></font>" : "<font color='green'><b>"+gpdata.getgIsQfillNum()+"</b></font>"))
		.append("</br>")
		.append("基金社保:" + (gpdata.getgIsJjNum() > 0 ? "<font color='red'><b>"+gpdata.getgIsJjNum()+"</b></font>" : "<font color='green'><b>"+gpdata.getgIsJjNum()+"</b></font>"))
		.append("&nbsp&nbsp|&nbsp&nbsp")
		.append("国家队:" + (gpdata.getgIsGjdNum() > 0 ? "<font color='red'><b>"+gpdata.getgIsGjdNum()+"</b></font>" : "<font color='green'><b>"+gpdata.getgIsGjdNum()+"</b></font>"))
		.append("&nbsp&nbsp|&nbsp&nbsp")
		.append("企业年金:" + (gpdata.getgIsQynjNum() > 0 ? "<font color='red'><b>"+gpdata.getgIsQynjNum()+"</b></font>" : "<font color='green'><b>"+gpdata.getgIsQynjNum()+"</b></font>"))
		.append("</br>")
		.append("股东增减比:" + (gdhs.getgZjbl() > 0 ? "<font color='red'><b>"+gdhs.getgZjbl()+"</b></font>" : "<font color='green'><b>"+gdhs.getgZjbl()+"</b></font>"))
		.append("&nbsp&nbsp|&nbsp&nbsp")
		.append("更新日期:" + DateUtil.format(gdhs.getgTime(), "yyyy-MM-dd"))
		.append("</br>")
		.append("总市值(亿):" + df.format(Math.abs(gdhs.getgZsz() / 100000000)));
    	
    	map.put("gSname", result.toString());
    	Date date = ((Date)map.get("gTdate"));
    	map.put("gTdate", DateUtil.format(date, "yyyy-MM-dd"));
    	
    	double gPbuy = ((Double)map.get("gPbuy"));
    	map.put("gPbuy", (gPbuy > 0 ? "<font color='red'><b>"+df.format(gPbuy/10000)+"</b></font>" : "<font color='green'><b>"+df.format(gPbuy/10000)+"</b></font>"));
    	
    	String gSalesDetail = ((String)map.get("gSalesDetail"));
    	map.put("gSalesDetail","<font color='red'><b>" + StringUtils.substringBefore(gSalesDetail, "--") + " -- </b></font>" +  StringUtils.substringAfter(gSalesDetail, "--"));
    }
}
